package com.gitee.l0km.codegen.webclient;

import org.apache.commons.cli.Options;

import com.gitee.l0km.codegen.base.generator.CodeWriter;
import com.gitee.l0km.codegen.base.generator.CxxCodeWriter;
import com.gitee.l0km.codegen.base.generator.Generator;
import com.gitee.l0km.codegen.base.generator.GeneratorConfiguration;
import com.gitee.l0km.com4j.cli.Context;

/**
 * 
 * gsoap stub相关代码生成
 * @author guyadong
 *
 */
public class GSoapStubGenerator extends Generator {
	private final GSoapStubOptions options = GSoapStubOptions.getInstance();
	protected GSoapStubConfiguration config;

	public GSoapStubGenerator() {
		config = new GSoapStubConfiguration();
	}

	public static void main(String[] args) {
		new GSoapStubGenerator().parseCommandLine(args).initEngine().generate();
	}

	@Override
	protected CodeWriter getCodeWriter() {
		return new CxxCodeWriter(config.getOutputLocation());
	}

	@Override
	protected Context createEngineContext() {
		Context context = super.createEngineContext();
		GSoapStub newSourceInfo = new GSoapStub(config.getServiceClass(), config.getStubFolder(), config.getStubPrefix());
		context.setProperty(SOURCE_INFO, newSourceInfo);
		return context;
	}

	@Override
	protected Options getOptions() {
		return options.getOptions();
	}

	@Override
	protected GeneratorConfiguration getGeneratorConfiguration() {
		return config;
	}

}
